package com.cogwheel.framework.util;

public class CRectangle {
	public float x, y, width, height = 0;
	public CRectangle(float x, float y, float width, float height){
		this.x = x; this.y = y; this.width = width; this.height = height;
	}
	public CRectangle(CPoint position, float width, float height){
		this(position.x, position.y, width, height);
	}
	
	public boolean Intersects(CRectangle rect){
		if(x - width/2 < rect.width + rect.x && width + (x - width/2) > rect.x 
		&& y - height/2 < rect.height + rect.y && height + (y - height/2) > rect.y) return true;
		else return false;
	}
	
	public boolean CInterseccts(CRectangle rectangle){
			return (Math.abs(x - rectangle.x) * 2 < (width + rectangle.width)) && (Math.abs(y - rectangle.y) * 2 < (height + rectangle.height));
	}
	
	public void CWGSetPosition(CPoint pos){
		this.x = pos.x; this.y = pos.y;
	}
}

































